/**
 * There are code generation
 */
package com.neusoft.lohas.modules.ivm.service.workflow;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.neusoft.lohas.common.persistence.Page;
import com.neusoft.lohas.common.service.BaseService;
import com.neusoft.lohas.modules.ivm.entity.workflow.WorkFlowDetail;
import com.neusoft.lohas.modules.ivm.dao.workflow.WorkFlowDetailDao;

/**
 * 流程详情Service
 * @author Jackie.Liu
 * @version 2014-12-21
 */
@Component
@Transactional(readOnly = true)
public class WorkFlowDetailService extends BaseService {

	@Autowired
	private WorkFlowDetailDao workFlowDetailDao;
	
	public WorkFlowDetail get(String id) {
		return workFlowDetailDao.get(id);
	}
	
	public Page<WorkFlowDetail> find(Page<WorkFlowDetail> page, WorkFlowDetail workFlowDetail) {
		DetachedCriteria dc = workFlowDetailDao.createDetachedCriteria();
		dc.add(Restrictions.eq(WorkFlowDetail.FIELD_DEL_FLAG, WorkFlowDetail.DEL_FLAG_NORMAL));
		dc.addOrder(Order.asc("createDate"));
		return workFlowDetailDao.find(page, dc);
	}
	
	@Transactional(readOnly = false)
	public void save(WorkFlowDetail workFlowDetail) {
		workFlowDetailDao.save(workFlowDetail);
	}
	
	@Transactional(readOnly = false)
	public void delete(String id) {
		workFlowDetailDao.deleteById(id);
	}
	
}
